using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
using System.Data.SqlTypes;
namespace BusinessObjects.BO_GetObjects {
    public static class BO_cms_users {
        public static DataTable Filter(int startIndex, int pageCount, string keyword) {
            try {
                usp_cms_users_filter entity = new usp_cms_users_filter();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.KEYWORD = keyword;
                return BO_Actions<usp_cms_users_filter>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static bool Lock(string user_id, string spliter, int lock_type, DateTime lock_date, SqlDateTime expire_date, string reason, string lock_by) {
            try {
                usp_cms_users_lock entity = new usp_cms_users_lock();
                entity.USER_ID = user_id;
                entity.LOCK_DATE = lock_date;
                entity.LOCK_TYPE = lock_type;
                entity.REASON = reason;
                entity.SPLITER = spliter;
                entity.EXPIRE_DATE = expire_date;
                entity.LOCK_BY = lock_by;
                return BO_Actions<usp_cms_users_lock>.ExecuteAndReturnBooleanValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static string ChangePassword(string username, string old_password, string new_password) {
            try {
                usp_cms_users_changed_password entity = new usp_cms_users_changed_password();
                entity.USER_NAME = username;
                entity.OLD_PASSWORD = old_password;
                entity.NEW_PASSWORD = new_password;
                return BO_Actions<usp_cms_users_changed_password>.ExecuteAndReturnStringValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static string ResetPassword(string username, string email) {
            try {
                usp_cms_users_reset_password entity = new usp_cms_users_reset_password();
                entity.USER_NAME = username;
                entity.EMAIL = email;
                return BO_Actions<usp_cms_users_reset_password>.ExecuteAndReturnStringValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable Authentication(string username, string password) {
            try {
                usp_cms_users_authentication entity = new usp_cms_users_authentication();
                entity.USER_NAME = username;
                entity.PASS_WORD = password;
                return BO_Actions<usp_cms_users_authentication>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable SelectAll(int status) {
            try {
                usp_cms_users_select_all entity = new usp_cms_users_select_all();
                entity.STATUS = status;
                return BO_Actions<usp_cms_users_select_all>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status) {
            try {
                usp_cms_users_select_top entity = new usp_cms_users_select_top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return BO_Actions<usp_cms_users_select_top>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable Search(int user_id) {
            try {
                usp_cms_users_search entity = new usp_cms_users_search();
                entity.USER_ID = user_id;

                return BO_Actions<usp_cms_users_search>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status) {
            try {
                usp_cms_users_select_paged entity = new usp_cms_users_select_paged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return BO_Actions<usp_cms_users_select_paged>.ExecuteAndReturnDataTable(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static string Insert(int group_user_id, string full_name, string user_name, string pass_word, string phone_number, string address, string email, bool is_locked, SqlDateTime locked_date, string locked_by, string reason_locked, SqlDateTime unlock_date, string unlock_by, string reason_unlock, SqlDateTime first_login_date, SqlDateTime last_login_date, SqlDateTime last_password_changed_date, int login_failure_count, int order_display, DateTime created_date, string created_by, SqlDateTime modify_date, string modify_by, bool status) {
            try {
                usp_cms_users_insert entity = new usp_cms_users_insert();
                entity.GROUP_USER_ID = group_user_id;
                entity.FULL_NAME = full_name;
                entity.USER_NAME = user_name;
                entity.PASS_WORD = pass_word;
                entity.PHONE_NUMBER = phone_number;
                entity.ADDRESS = address;
                entity.EMAIL = email;
                entity.IS_LOCKED = is_locked;
                entity.LOCKED_DATE = locked_date;
                entity.LOCKED_BY = locked_by;
                entity.REASON_LOCKED = reason_locked;
                entity.UNLOCK_DATE = unlock_date;
                entity.UNLOCK_BY = unlock_by;
                entity.REASON_UNLOCK = reason_unlock;
                entity.FIRST_LOGIN_DATE = first_login_date;
                entity.LAST_LOGIN_DATE = last_login_date;
                entity.LAST_PASSWORD_CHANGED_DATE = last_password_changed_date;
                entity.LOGIN_FAILURE_COUNT = login_failure_count;
                entity.ORDER_DISPLAY = order_display;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return BO_Actions<usp_cms_users_insert>.ExecuteAndReturnStringValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static string Update(int user_id, int group_user_id, string full_name, string user_name, string pass_word, string phone_number, string address, string email, DateTime modify_date, string modify_by, bool status) {
            try {
                usp_cms_users_update entity = new usp_cms_users_update();
                entity.USER_ID = user_id;
                entity.GROUP_USER_ID = group_user_id;
                entity.FULL_NAME = full_name;
                entity.USER_NAME = user_name;
                entity.PASS_WORD = pass_word;
                entity.PHONE_NUMBER = phone_number;
                entity.ADDRESS = address;
                entity.EMAIL = email;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return BO_Actions<usp_cms_users_update>.ExecuteAndReturnStringValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static bool Delete(string ids, string spliter, int delete_type) {
            try {
                usp_cms_users_delete entity = new usp_cms_users_delete();
                entity.IDS = ids;
                entity.SPLITER = spliter;
                entity.DELETE_TYPE = delete_type;

                return BO_Actions<usp_cms_users_delete>.ExecuteAndReturnBooleanValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
        public static bool Restore(int user_id) {
            try {
                usp_cms_users_restore entity = new usp_cms_users_restore();
                entity.USER_ID = user_id;

                return BO_Actions<usp_cms_users_restore>.ExecuteAndReturnBooleanValue(entity);
            } catch (Exception ex) {
                throw ex;
            }
        }
    }
}

